package com.elite.groovy.callback


import org.springframework.jdbc.core.JdbcTemplate;
import com.elite.groovy.util.EliteBean;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.elite.groovy.util.Util

import javax.servlet.http.HttpServletRequest
import javax.servlet.http.HttpServletResponse;
import javax.sql.DataSource;
/**
 * @use 续保外呼，根据销管系统推送的数据，调用车承保系统获取上年保单信息
 * @author admin
 *
 */

public class GetPolicyInfo implements ServiceBackInvoke{
    private static final Log log=LogFactory.getLog(GetPolicyInfo.class);

    private String charset = "utf-8"; //设置字符集
    private int timeout = 100000; //设置请求超时时间
    private int enableSSLflag = 0;
    @Override
    String doCallBack(EliteBean eliteBean, HttpServletRequest request, HttpServletResponse response) {

        def v_batch_guid=UUID.randomUUID().toString();
        eliteBean.update("""update XB_CUST_CASE set batch_guid = '${v_batch_guid}',CUST_STATUS=0 where CUST_STATUS='1' and rownum<101""", "dataSource");

        try {
            def mapn = "";
            def voctable = eliteBean.chaxun_sql("""select c.RELATION_ID, case when c.CHANNELFLAG='OLS' then '000001002' else '000001001' end MerchantSubCode, c.POLICYNO BusinessNo, c.COMCODE ComCode, c.frameno VINNo from XB_CUST_CASE c where c.batch_guid = '${v_batch_guid}' """, "dataSource");
            log.debug("voctable:" + voctable);

            if (voctable != null && voctable.size() > 0) {
                for (def i = 0; i < voctable.size(); i++) {
                    mapn = voctable[i];
                    def RELATION_ID = mapn.get("RELATION_ID");
                    //String updatesql = "update XB_CUST_CASE set CUST_STATUS=0 where RELATION_ID='$RELATION_ID'";
                    //eliteBean.update(updatesql, "dataSource");
                }
            }

            def querySql = "select t.url, t.dd_use_id, t.dd_key from SYSC_INTERFACE t where t.urltype='CX001'";
            def quelist = eliteBean.chaxun_sql(querySql, "dataSource");
            def map3 = quelist[0];
            def v_webserviceurl = map3.get("url");
            def v_stringfield5 = map3.get("dd_use_id");
            def v_token = map3.get("dd_key");

            JdbcTemplate jt = new JdbcTemplate(eliteBean.getDataSource());
            Map headMap = new HashMap();
            headMap.put("Content-Type", "text/xml;charset=UTF-8");
            //headMap.put("SOAPAction","/im/sendMessage");
            if (voctable != null && voctable.size() > 0) {
                for (def i = 0; i < voctable.size(); i++) {
                    mapn = voctable[i];
                    println "mapn:" + mapn;
                    def RELATION_ID = mapn.get("RELATION_ID");
                    def SystemCode = "80026";
                    def ComCode = mapn.get("ComCode");  //机构
                    def MerchantCode = "000001"; //000001,直销业务
                    def MerchantSubCode = mapn.get("MerchantSubCode"); //000001001,直销业务(电销) / 000001002,直销业务(网销)
                    def BusinessNo = mapn.get("BusinessNo");  //保单号
                    def VINNo2 = mapn.get("VINNo");  //车架号
                    def url = v_webserviceurl;  //url
                    def UserCode = v_stringfield5;  //用户账号
                    def Password = v_token;  //token

                    def smsBody = """
                    <PACKET type="REQUEST" version="1.0">
                      <HEAD>
                        <SystemCode>$SystemCode</SystemCode>
                        <UserCode>$UserCode</UserCode>
                        <Password>$Password</Password>
                        <ComCode>$ComCode</ComCode>
                        <MerchantCode>$MerchantCode</MerchantCode>
                        <MerchantSubCode>$MerchantSubCode</MerchantSubCode>
                      </HEAD>
                      <BODY>
                        <BasePart>
                          <LicenseNo/>
                          <VINNo>$VINNo2</VINNo>
                          <PolicyNo>$BusinessNo</PolicyNo>
                        </BasePart>
                      </BODY>
                    </PACKET>
							""";
                    log.debug("smsBody:" + smsBody);
                    def callBack1 = Util.doHttpPostUseHead(url, smsBody, "UTF-8", 30000, 0, headMap);

                    /*def callBack1 = """<PACKET>
    <HEAD>
        <SystemCode>80026</SystemCode>
        <ResponseType>1</ResponseType>
    </HEAD>
    <BODY>
        <Vehicle>
            <LicenseNo>粤ZM071澳</LicenseNo>
            <LicenseColorCode>01</LicenseColorCode>
            <LicenseColorName>蓝</LicenseColorName>
            <ColorName>其他</ColorName>
            <LicenseTypeCode>02</LicenseTypeCode>
            <LicenseTypeName>小型汽车号牌</LicenseTypeName>
            <CarTypeCode>001</CarTypeCode>
            <CarTypeName>6座以下客车</CarTypeName>
            <UseKindCode>002</UseKindCode>
            <UseKindName>非营业</UseKindName>
            <EnrollDate>20210511</EnrollDate>
            <VINNo>DGTRHTRRH7687661B</VINNo>
            <UseYears>0</UseYears>
            <EngineNo>RH7687661B</EngineNo>
            <VehicleType>K33</VehicleType>
            <WholeWeight>963.0</WholeWeight>
            <SeatCountShow>5</SeatCountShow>
            <TonCountShow>0.0</TonCountShow>
            <CarDealerName>斯帕可SPARK 1.0L轿车</CarDealerName>
            <AllMass>0.0</AllMass>
            <NewVehicleFlag>1</NewVehicleFlag>
            <ChgOwnerFlag>0</ChgOwnerFlag>
            <EcdemicVehicleFlag>2</EcdemicVehicleFlag>
            <CarLoanFlag>0</CarLoanFlag>
            <ExhaustScaleShow>0.995</ExhaustScaleShow>
            <ColorCode>99</ColorCode>
            <CountryNatureCode>A</CountryNatureCode>
            <CountryNatureName>进口</CountryNatureName>
            <CarInsuredRelationCode>1</CarInsuredRelationCode>
            <CarInsuredRelationName>002</CarInsuredRelationName>
            <CarOwner>深圳网络科技有限公司</CarOwner>
            <IdentifyType>00</IdentifyType>
            <IdentifyNumber>896541236547896541</IdentifyNumber>
            <CarAttachNatureCode>002</CarAttachNatureCode>
            <CarAttachNatureName>002</CarAttachNatureName>
            <RunAreaCode>04</RunAreaCode>
            <RunAreaName>中国境内(不含港澳台)</RunAreaName>
            <CarCheckStatus>2</CarCheckStatus>
            <CarCheckTime>20210513105200</CarCheckTime>
            <NoCheckReason>3</NoCheckReason>
            <FuelType>0</FuelType>
            <VehiclePrice>68800.0</VehiclePrice>
            <ActualValue>68800.0</ActualValue>
            <MadeFactory>美国通用汽车公司雪佛兰部</MadeFactory>
            <ModelCode>SPI1001TYQ</ModelCode>
            <BrandName>斯帕可SPARK 1.0L轿车</BrandName>
            <AddonCount>0</AddonCount>
            <LoyaltyFlag>0</LoyaltyFlag>
            <SafeDeviceName></SafeDeviceName>
            <VehiclePriceOrigin>68800.0</VehiclePriceOrigin>
            <NoticeType>SPARK 1.0L</NoticeType>
            <CarName>斯帕可SPARK 1.0L轿车</CarName>
            <VehicleCode>BXFFSQUB0001</VehicleCode>
        </Vehicle>
        <DriverList></DriverList>
        <RiskList>
            <Risk>
                <BusinessNo>210010020211101000515</BusinessNo>
                <Type>2</Type>
                <RiskCode>1101</RiskCode>
                <QuerySequenceNo>02DHIC44012100000000000003050Z</QuerySequenceNo>
                <ValidNo>02DHIC44012100000000000003050Z</ValidNo>
                <BusinessStatus>1</BusinessStatus>
                <ComCode>10010010</ComCode>
                <HandlerCode>1000003169</HandlerCode>
                <HandlerName>程娜</HandlerName>
                <BusinessNatureCode>0</BusinessNatureCode>
                <BusinessNatureName>0</BusinessNatureName>
                <ShareHolderFlag>0</ShareHolderFlag>
                <BusinessPlate>0</BusinessPlate>
                <BusinessClass>01</BusinessClass>
                <BusinessClassification>01</BusinessClassification>
                <FarmFlag>10</FarmFlag>
                <ProposalNo>110010020211101000562</ProposalNo>
                <PolicyNo>210010020211101000515</PolicyNo>
                <CoinsFlag>0</CoinsFlag>
                <OperateDate class="sql-timestamp">20210513</OperateDate>
                <StartDate class="sql-timestamp">20210514</StartDate>
                <StartHour>0</StartHour>
                <EndDate class="sql-timestamp">20220825</EndDate>
                <EndHour>24</EndHour>
                <CommissionRate>0.0</CommissionRate>
                <CommissionAccount>0.0</CommissionAccount>
                <Discount>1.0</Discount>
                <SumDiscount>0.0</SumDiscount>
                <SumPremium>1000.00</SumPremium>
                <SumPremiumNT>943.40</SumPremiumNT>
                <SumPremiumTax>56.60</SumPremiumTax>
                <TaxRate>0.06</TaxRate>
                <SumSubPremium>0.0</SumSubPremium>
                <SumAmount>200000.0</SumAmount>
                <ArgueSolutionCode>1</ArgueSolutionCode>
                <ArgueSolutionName>诉讼</ArgueSolutionName>
                <ShortRateFlag>4</ShortRateFlag>
                <OperatorName>肖雪萍</OperatorName>
                <GoalInsuredFlag>0</GoalInsuredFlag>
                <Coverage>
                    <CoverageClassCode>1</CoverageClassCode>
                    <CoverageCode>BZ</CoverageCode>
                    <CoverageName>机动车交通事故责任强制险</CoverageName>
                    <RiskCode>1101</RiskCode>
                    <Amount>200000.0</Amount>
                    <NoDutyRate>0</NoDutyRate>
                    <UnitAmount>0.0</UnitAmount>
                    <Quantity>0</Quantity>
                    <Value>0.0</Value>
                    <DeductibleRate>0.0</DeductibleRate>
                    <Deductible>0.0</Deductible>
                    <Rate>0.0</Rate>
                    <BasePremium>1000.0</BasePremium>
                    <BenchMarkPremium>1000.0</BenchMarkPremium>
                    <SumPremium>1000.00</SumPremium>
                    <SumPremiumNT>943.40</SumPremiumNT>
                    <SumPremiumTax>56.60</SumPremiumTax>
                    <TaxRate>0.06</TaxRate>
                    <DisCount>1.0</DisCount>
                    <AdjustRate>1.0</AdjustRate>
                    <AccidInjuryMedicUnitAmount>0.0</AccidInjuryMedicUnitAmount>
                </Coverage>
                <Engage>
                    <ClauseCode>T0129</ClauseCode>
                    <ClauseTitle>实物赔付特别约定</ClauseTitle>
                    <ClauseDesc>保险人可以以货币赔偿、实物赔偿或实际修复方式赔偿，但以实物赔偿或实际修复方式赔偿须取得被保险人同意。</ClauseDesc>
                </Engage>
                <PricePlan></PricePlan>
                <AvailableBalanceRate>0.0</AvailableBalanceRate>
                <AvailableBalanceAmount>0.0</AvailableBalanceAmount>
            </Risk>
            <Risk>
                <BusinessNo>210010020211230000014</BusinessNo>
                <Type>2</Type>
                <RiskCode>1230</RiskCode>
                <QuerySequenceNo>V0201DHIC44012100000000003077Z</QuerySequenceNo>
                <ValidNo>V0201DHIC44012100000000003077Z</ValidNo>
                <BusinessStatus>1</BusinessStatus>
                <ComCode>10010010</ComCode>
                <HandlerCode>1000003169</HandlerCode>
                <HandlerName>程娜</HandlerName>
                <BusinessNatureCode>0</BusinessNatureCode>
                <BusinessNatureName>0</BusinessNatureName>
                <ShareHolderFlag>0</ShareHolderFlag>
                <BusinessPlate>0</BusinessPlate>
                <BusinessClass>01</BusinessClass>
                <BusinessClassification>01</BusinessClassification>
                <FarmFlag>10</FarmFlag>
                <ProposalNo>110010020211230000078</ProposalNo>
                <PolicyNo>210010020211230000014</PolicyNo>
                <CoinsFlag>0</CoinsFlag>
                <OperateDate class="sql-timestamp">20210513</OperateDate>
                <StartDate class="sql-timestamp">20210514</StartDate>
                <StartHour>0</StartHour>
                <EndDate class="sql-timestamp">20220513</EndDate>
                <EndHour>24</EndHour>
                <CommissionRate>0.0</CommissionRate>
                <CommissionAccount>0.0</CommissionAccount>
                <Discount>0.6897</Discount>
                <SumDiscount>318.83</SumDiscount>
                <SumPremium>708.64</SumPremium>
                <SumPremiumNT>668.53</SumPremiumNT>
                <SumPremiumTax>40.11</SumPremiumTax>
                <TaxRate>0.06</TaxRate>
                <SumSubPremium>0.0</SumSubPremium>
                <SumAmount>1050000.0</SumAmount>
                <ArgueSolutionCode>1</ArgueSolutionCode>
                <ArgueSolutionName>诉讼</ArgueSolutionName>
                <ShortRateFlag>4</ShortRateFlag>
                <OperatorName>肖雪萍</OperatorName>
                <GoalInsuredFlag>0</GoalInsuredFlag>
                <ShortRate>100.0</ShortRate>
                <AdditionalCostRate>0.25</AdditionalCostRate>
                <AutoPriceDemandNo>G10010020211230C6697C61E23B4444A77EC0EACB04C6F9</AutoPriceDemandNo>
                <Coverage>
                    <CoverageClassCode>1</CoverageClassCode>
                    <CoverageCode>B</CoverageCode>
                    <CoverageName>机动车第三者责任保险</CoverageName>
                    <RiskCode>1230</RiskCode>
                    <Amount>1000000.0</Amount>
                    <NoDutyRate>0</NoDutyRate>
                    <UnitAmount>0.0</UnitAmount>
                    <Quantity>0</Quantity>
                    <ModeCode>0</ModeCode>
                    <Value>0.0</Value>
                    <DeductibleRate>1.0</DeductibleRate>
                    <Deductible>0.0</Deductible>
                    <Rate>0.0</Rate>
                    <BasePremium>695.02</BasePremium>
                    <BenchMarkPremium>926.69</BenchMarkPremium>
                    <SumPremium>639.14</SumPremium>
                    <SumPremiumNT>602.96</SumPremiumNT>
                    <SumPremiumTax>36.18</SumPremiumTax>
                    <TaxRate>0.06</TaxRate>
                    <DisCount>0.6897</DisCount>
                    <AdjustRate>1.0</AdjustRate>
                    <DeductiblePremium>0.0</DeductiblePremium>
                    <AccidInjuryMedicUnitAmount>0.0</AccidInjuryMedicUnitAmount>
                </Coverage>
                <Coverage>
                    <CoverageClassCode>1</CoverageClassCode>
                    <CoverageCode>D11</CoverageCode>
                    <CoverageName>机动车车上人员责任保险（司机）</CoverageName>
                    <RiskCode>1230</RiskCode>
                    <Amount>10000.0</Amount>
                    <NoDutyRate>0</NoDutyRate>
                    <UnitAmount>0.0</UnitAmount>
                    <Quantity>0</Quantity>
                    <ModeCode>0</ModeCode>
                    <Value>0.0</Value>
                    <DeductibleRate>1.0</DeductibleRate>
                    <Deductible>0.0</Deductible>
                    <Rate>0.2174</Rate>
                    <BasePremium>0.0</BasePremium>
                    <BenchMarkPremium>28.99</BenchMarkPremium>
                    <SumPremium>19.99</SumPremium>
                    <SumPremiumNT>18.86</SumPremiumNT>
                    <SumPremiumTax>1.13</SumPremiumTax>
                    <TaxRate>0.06</TaxRate>
                    <DisCount>0.6897</DisCount>
                    <AdjustRate>1.0</AdjustRate>
                    <DeductiblePremium>0.0</DeductiblePremium>
                    <AccidInjuryMedicUnitAmount>0.0</AccidInjuryMedicUnitAmount>
                </Coverage>
                <Coverage>
                    <CoverageClassCode>1</CoverageClassCode>
                    <CoverageCode>D12</CoverageCode>
                    <CoverageName>机动车车上人员责任保险（乘客）</CoverageName>
                    <RiskCode>1230</RiskCode>
                    <Amount>40000.0</Amount>
                    <NoDutyRate>0</NoDutyRate>
                    <UnitAmount>10000.0</UnitAmount>
                    <Quantity>4</Quantity>
                    <ModeCode>0</ModeCode>
                    <Value>0.0</Value>
                    <DeductibleRate>1.0</DeductibleRate>
                    <Deductible>0.0</Deductible>
                    <Rate>0.1346</Rate>
                    <BasePremium>0.0</BasePremium>
                    <BenchMarkPremium>71.79</BenchMarkPremium>
                    <SumPremium>49.51</SumPremium>
                    <SumPremiumNT>46.71</SumPremiumNT>
                    <SumPremiumTax>2.80</SumPremiumTax>
                    <TaxRate>0.06</TaxRate>
                    <DisCount>0.6897</DisCount>
                    <AdjustRate>1.0</AdjustRate>
                    <DeductiblePremium>0.0</DeductiblePremium>
                    <AccidInjuryMedicUnitAmount>0.0</AccidInjuryMedicUnitAmount>
                </Coverage>
                <ProfitSet>
                    <ProfitSetCode>37</ProfitSetCode>
                    <ProfitSetName>无赔款优待系数</ProfitSetName>
                    <ProfitFactorSetCode>0</ProfitFactorSetCode>
                    <ProfitFactorSetName>连续承保0年且出险0次</ProfitFactorSetName>
                    <ProfitRate>1.0</ProfitRate>
                </ProfitSet>
                <ProfitSet>
                    <ProfitSetCode>36</ProfitSetCode>
                    <ProfitSetName>自主定价系数</ProfitSetName>
                    <ProfitFactorSetCode>A</ProfitFactorSetCode>
                    <ProfitFactorSetName>自主定价系数</ProfitFactorSetName>
                    <ProfitRate>0.689675</ProfitRate>
                </ProfitSet>
                <Engage>
                    <ClauseCode>T0048</ClauseCode>
                    <ClauseTitle>非营业车辆特别约定</ClauseTitle>
                    <ClauseDesc>保险车辆如从事营业性用途，发生保险责任范围内的事故，保险人不承担赔偿责任。</ClauseDesc>
                </Engage>
                <Engage>
                    <ClauseCode>T0129</ClauseCode>
                    <ClauseTitle>实物赔付特别约定</ClauseTitle>
                    <ClauseDesc>保险人可以以货币赔偿、实物赔偿或实际修复方式赔偿，但以实物赔偿或实际修复方式赔偿须取得被保险人同意。</ClauseDesc>
                </Engage>
                <PricePlan></PricePlan>
                <AvailableBalanceRate>0.0</AvailableBalanceRate>
                <AvailableBalanceAmount>0.0</AvailableBalanceAmount>
            </Risk>
        </RiskList>
        <InsuredList>
            <Insured>
                <InsuredFlag>1</InsuredFlag>
                <InsuredNature>4</InsuredNature>
                <InsuredName>深圳网络科技有限公司</InsuredName>
                <InsuredAddress>广东省深圳市福田</InsuredAddress>
                <IdentifytypeCode>00</IdentifytypeCode>
                <IdentifytypeName>其他</IdentifytypeName>
                <IdentifyNumber>896541236547896541</IdentifyNumber>
                <PostCode>000000</PostCode>
                <PhoneNumber>99877234</PhoneNumber>
                <Mobile>13617738303</Mobile>
                <Email>735569870@qq.com</Email>
                <LinkerName>王小飞</LinkerName>
                <IdValidDate>2023-07-06</IdValidDate>
                <Province>440000</Province>
                <City>440300</City>
                <Country>440304</Country>
            </Insured>
            <Insured>
                <InsuredFlag>2</InsuredFlag>
                <InsuredNature>4</InsuredNature>
                <InsuredName>深圳网络科技有限公司</InsuredName>
                <InsuredAddress>广东省深圳市福田</InsuredAddress>
                <IdentifytypeCode>00</IdentifytypeCode>
                <IdentifyNumber>896541236547896541</IdentifyNumber>
                <PostCode>000000</PostCode>
                <PhoneNumber>99877234</PhoneNumber>
                <Mobile>13617738303</Mobile>
                <Email>735569870@qq.com</Email>
                <LinkerName>王小飞</LinkerName>
                <IdValidDate>2023-07-06</IdValidDate>
                <Province>440000</Province>
                <City>440300</City>
                <Country>440304</Country>
            </Insured>
        </InsuredList>
        <InsuredTax>
            <InsuredFlag>2</InsuredFlag>
            <TaxCustomerType>2</TaxCustomerType>
            <TaxPayerType>1</TaxPayerType>
            <TaxPayerNumber>896541236547896541</TaxPayerNumber>
            <TaxRegistAddress>广东省深圳市福田</TaxRegistAddress>
            <BankName>招商银行</BankName>
            <BankAccount>招商银行</BankAccount>
            <CompanyName>深圳网络科技有限公司</CompanyName>
            <IsInvoice>1</IsInvoice>
            <Mobile>13617738303</Mobile>
            <Email>735569870@qq.com</Email>
            <IdentifyType>00</IdentifyType>
            <IdentifyCode>896541236547896541</IdentifyCode>
        </InsuredTax>
        <SalesInfoList>
            <SalesInfo>
                <SalesType>0</SalesType>
                <SalesCode>1000003169</SalesCode>
                <SalesName>程娜</SalesName>
                <Certificate>131232dsf32424</Certificate>
            </SalesInfo>
        </SalesInfoList>
        <AgentInfoList></AgentInfoList>
        <VehicleTaxation>
            <TaxReliefFlag>7B</TaxReliefFlag>
            <TaxpayerName>深圳网络科技有限公司</TaxpayerName>
            <IdentifyType>00</IdentifyType>
            <TaxpayerCode>896541236547896541</TaxpayerCode>
            <TaxpayerIdentifier>896541236547896541</TaxpayerIdentifier>
            <AllMass>963.0</AllMass>
            <WholeWeight>963.0</WholeWeight>
            <CalculateMode>C2</CalculateMode>
            <TaxActual>0.0</TaxActual>
            <PreviousPay>0.0</PreviousPay>
            <LateFee>0.0</LateFee>
            <SumPayTax>0.0</SumPayTax>
        </VehicleTaxation>
        <InsuredAgentList></InsuredAgentList>
        <PhoneHolderList></PhoneHolderList>
        <SimplePrpallInfo></SimplePrpallInfo>
    </BODY>
</PACKET>""";*/

                    //----------------------------------
                    /*JSONObject jsonObject1 = XmlToJsonUtil.xml2Json(callBack1);
                    def BODY = jsonObject1.get("BODY");
                    def RiskList = BODY.get("RiskList");
                    log.debug("RiskList:" + RiskList);*/
                    //--------------------------------------------

                    log.debug("callBack1:" + callBack1);

                    def xmlstr = Util.Transform(callBack1);
                    def LIST = new XmlParser().parseText(xmlstr);
                    log.debug("LIST:" + LIST);
                    def ResponseType = LIST.HEAD.ResponseType.text();
                    def LicenseType = LIST.BODY.Vehicle.LicenseTypeName.text();  //LicenseType 号牌种类
                    def CarTypeCode = LIST.BODY.Vehicle.CarTypeCode.text(); //CarTypeCode 车辆种类
                    def CarTypeName = LIST.BODY.Vehicle.CarTypeName.text(); //车辆种类名称
                    def UseKindCode = LIST.BODY.Vehicle.UseKindCode.text(); //使用性质
                    def UseKindName = LIST.BODY.Vehicle.UseKindName.text(); //使用性质名称
                    def EnrollDate = LIST.BODY.Vehicle.EnrollDate.text(); //车辆初始登记日期
                    def VINNo = LIST.BODY.Vehicle.VINNo.text(); //车架号
                    log.debug("VINNo:" + VINNo);
                    def EngineNo = LIST.BODY.Vehicle.EngineNo.text(); //发动机号
                    def SeatCountShow = LIST.BODY.Vehicle.SeatCountShow.text(); //核定载客人数
                    def VehicleBrand = LIST.BODY.Vehicle.BrandName.text(); //上海新车 车辆品牌
                    def CarDealerName = LIST.BODY.Vehicle.CarDealerName.text(); //品牌型号
                    def ExhaustScaleShow = LIST.BODY.Vehicle.ExhaustScaleShow.text(); //排量(毫升)
                    def CILastPolicyNo = ""; //上年交强险投保保单号
                    def BILastPolicyNo = "";//上年商业险投保保单号
                    def CarOwner = LIST.BODY.Vehicle.CarOwner.text(); //车主
                    def IdentifyType = LIST.BODY.Vehicle.IdentifyType.text();  //证件类型
                    def IdentifyNumber = LIST.BODY.Vehicle.IdentifyNumber.text(); //证件号码
                    def VehiclePrice = LIST.BODY.Vehicle.VehiclePrice.text();  //新车购置价
                    def ModelCode = LIST.BODY.Vehicle.ModelCode.text(); //车型代码
                    def ActualValue = LIST.BODY.Vehicle.ActualValue.text(); //实际价值

                    InputStream  callback_xml = new  ByteArrayInputStream(callBack1.getBytes("UTF-8"));
                    //获取成功
                    if (ResponseType == "1") {
                        def sql="""insert into XB_POLICY_INFO(
                            RELATION_ID, LicenseType, CarTypeCode, CarTypeName, UseKindCode, UseKindName,
                            EnrollDate, VINNo, EngineNo, SeatCountShow, VehicleBrand, CarDealerName, 
                            ExhaustScaleShow, CILastPolicyNo, BILastPolicyNo, CarOwner, IdentifyType, IdentifyNumber, 
                            VehiclePrice, ModelCode, ActualValue, policy_response) values (
                            '${RELATION_ID}','${LicenseType}','${CarTypeCode}','${CarTypeName}','${UseKindCode}','${UseKindName}',
                            '${EnrollDate}','${VINNo}','${EngineNo}','${SeatCountShow}','${VehicleBrand}','${CarDealerName}',
                            '${ExhaustScaleShow}','${CILastPolicyNo}','${BILastPolicyNo}','${CarOwner}','${IdentifyType}','${IdentifyNumber}','${VehiclePrice}','${ModelCode}','${ActualValue}', ?)""";
                        jt.update(sql,callBack1);

                        String sql2 = "update XB_CUST_CASE set CUST_STATUS=2,UPDATE_DATE=sysdate,UPDATE_USER='SYSTEM' where RELATION_ID='$RELATION_ID'";
                        eliteBean.update(sql2, "dataSource");

                        String insertsql2 = """insert into tabc_xb_case(
                            RELATION_ID,ELITETASK_GUID,CUSTOMER_GUID,CREATE_USER,CREATE_DATE,
                            UPDATE_USER,UPDATE_DATE,CUSTLIST_XXX,POLICYNO,RISKCODE,
                            RISKNAME,LICENSENO,FRAMENO,APPLICODE,APPLINAME,
                            INSUREDCODE,INSUREDNAME,APPLI_PHONE,INSURED_PHONE,BUSINESSNATURE,
                            STARTDATE,ENDDATE,COMCODE,GROUPCODE,HANDLERCODE,
                            RENEWALFLAG,GROUPNO1,AGENTCODE,ACCEPT_YEARS,MAINPOLICYNO,
                            RISKCLASS,ISSUEORG,ISSUESTAFF,ORDERNUMBER,ISCAR,
                            APPLIIDENGTIFYNO,CARATTACHNATURE,USEKINDCODE,CARTYPE,RENEWALEXPIRETIME,
                            BUSINESSTYPE,AGENTCOMPANY,HANDLER1CODE,handleby_id,handlegroup_id,OBJECTIVETYPE
                            )
                            select
                            RELATION_ID,ELITETASK_GUID,CUSTOMER_GUID,CREATE_USER,CREATE_DATE,
                            UPDATE_USER,UPDATE_DATE,CUSTLIST_XXX,POLICYNO,RISKCODE,
                            RISKNAME,LICENSENO,FRAMENO,APPLICODE,APPLINAME,
                            INSUREDCODE,INSUREDNAME,APPLI_PHONE,INSURED_PHONE,BUSINESSNATURE,
                            STARTDATE,ENDDATE,COMCODE,GROUPCODE,HANDLERCODE,
                            RENEWALFLAG,GROUPNO1,AGENTCODE,ACCEPT_YEARS,MAINPOLICYNO,
                            RISKCLASS,ISSUEORG,ISSUESTAFF,ORDERNUMBER,ISCAR,
                            APPLIIDENGTIFYNO,CARATTACHNATURE,USEKINDCODE,CARTYPE,RENEWALEXPIRETIME,
                            BUSINESSTYPE,AGENTCOMPANY,HANDLER1CODE,'','',OBJECTIVETYPE
                            from
                            XB_CUST_CASE
                            where RELATION_ID='$RELATION_ID'""";
                        eliteBean.update(insertsql2, "dataSource");


                        def selectcount="select count(*) count1 from TABC_XB_CASE A, elitetask B where A.customer_guid = B.customer_guid and B.elitetaskstatus='OPEN' and A.relation_id='$RELATION_ID' and B.handleby_id is not null";
                        def selectcounts=eliteBean.chaxun_sql(selectcount,"dataSource");
                        log.debug("selectcounts-------------------------------"+selectcounts);
                        def count=selectcounts[0].COUNT1;
                        log.debug("count-------------------------------"+count);

                        if(count>0){
                            def selectRow = "select B.handleby_id as handleby_id, B.handlegroup_id as handlegroup_id from TABC_XB_CASE A, elitetask B where A.customer_guid = B.customer_guid and B.elitetaskstatus='OPEN' and A.relation_id='$RELATION_ID' and B.handleby_id is not null";
                            def RowLists = eliteBean.chaxun_sql(selectRow, "dataSource");
                            log.debug("RowLists-------------------------------"+RowLists);
                            def RowList = RowLists[0];

                            def Row_handleby_id = RowList.get("handleby_id");
                            def Row_handlegroup_id = RowList.get("handlegroup_id");
                            String updatesql1 = "update tabc_xb_case set handleby_id='${Row_handleby_id}', handlegroup_id='${Row_handlegroup_id}', sharestatus = 2 where RELATION_ID = '$RELATION_ID'";
                            eliteBean.update(updatesql1, "dataSource");

                        }

                        String insertsql3 = """insert into objective
                            (objective_guid, objectivetype_id, handleby_id, handlegroup_id, expireddate,
                            customer_guid, createdby, createddate, custlistname, customerlevel,
                            expectstarttime, expectendtime, trytimes, max_attempt,templable,
                            objectivesubstatus, map_id, curstep_id_map, owner, handlerole_id,
                            lastassigndate, objectivestatus)
                            select
                            tt.relation_id,'VIQNMW','','',sysdate+7,
                            tt.customer_guid,'SYSTEM',sysdate,tt.custlist_xxx,'',
                            sysdate,sysdate+7,0,99,tt.custlist_xxx,
                            'OPEN','FQ2KML','2HJR2Y','','',
                            sysdate,'OPEN'
                            from tabc_xb_case tt
                            where RELATION_ID='$RELATION_ID'""";
                        eliteBean.update(insertsql3, "dataSource");

                        String insertsql4 = """insert into elitetask
                            (elitetask_guid, objective_guid, objectivetype_id, expectstarttime, expectendtime, attempt, 
                            max_attempt, handleby_id, handlegroup_id, handlerole_id, createdby, createddate,
                            custlistname, customer_guid, workorderframe_id, curstepstatus, curstep_id_map, map_id, 
                            objectivesubstatus, elitetaskstatus, obflag, lastassigndate, obstatus)
                            select
                            tc.elitetask_guid, o.objective_guid, o.objectivetype_id, o.expectstarttime, o.expectendtime, 0, 
                            o.max_attempt, o.handleby_id, o.handlegroup_id, o.Handlerole_id, 'SYSTEM', sysdate, 
                            o.custlistname, o.customer_guid, 'VIQNMW', 'OPEN', '2HJR2Y', 'FQ2KML', 
                            'OPEN', 'OPEN', 1, o.lastassigndate, 'OPEN'
                            from objective o
                            left join XB_CUST_CASE tc on o.objective_guid = tc.relation_id
                            where tc.RELATION_ID='$RELATION_ID'""";
                        eliteBean.update(insertsql4, "dataSource");

                        String insertsql5 = """insert into assign_his 
                        (ASSIGN_GUID, CUSTOMER_GUID, OBJECTIVE_GUID, 
                        NEWHANDLEBY_ID, NEWHANDLEGROUP_ID, ASSIGNDATE, ASSIGNCOMMENTS) 
                        select 
                        SYS_guid(), o.CUSTOMER_GUID, o.objective_guid, 
                        handleby_id, handlegroup_id, sysdate, case when '${count}' >0 then '关联任务，自动分配。' else '任务新建' end 
                        from objective o left join XB_CUST_CASE tc on o.objective_guid = tc.relation_id 
                        where tc.RELATION_ID='$RELATION_ID'""";
                        eliteBean.update(insertsql5, "dataSource");

                        log.debug("----------GetPolicyInfo(续保外呼，获取上年保单信息)成功----------");
                    } else {
                        String sql3 = "update XB_CUST_CASE set CUST_STATUS=99, UPDATE_DATE=sysdate, UPDATE_USER='SYSTEM' where RELATION_ID='$RELATION_ID'";
                        eliteBean.update(sql3, "dataSource");
                    }
                }
            }
        }
        //groovy异常
        catch(Exception e){
            eliteBean.update("""update XB_CUST_CASE set batch_guid = '${v_batch_guid}',CUST_STATUS=1 where CUST_STATUS=0 and batch_guid = '${v_batch_guid}'""", "dataSource");

            log.debug("----------GetPolicyInfo(续保外呼，获取上年保单信息)异常----------");
            log.error("" ,e);
        }
        return "1";
    }


}
